package com.example.aicode.chat.guardrails;

import dev.langchain4j.data.message.UserMessage;
import dev.langchain4j.guardrail.InputGuardrail;
import dev.langchain4j.guardrail.InputGuardrailResult;
import org.apache.commons.lang3.StringUtils;

public class AiServiceGuardrails implements InputGuardrail {

    @Override
    public InputGuardrailResult validate(UserMessage message) {
        String text = message.singleText();
        if (StringUtils.equals(text, "fuck")) {
            return fatal("敏感词：" + text);
        }
        return success();
    }
}
